package com.cn.lp.jpa.cq.test.domain;

import java.util.Optional;

/**
 * 任务触发器
 */
public interface TaskTrigger {

    default boolean canTrigger() {
        return getNextTriggerTime()
            .map(nt -> System.currentTimeMillis() >= nt)
            .orElse(false);
    }

    Optional<Long> getTriggerTimeAfter(long currentTime);

    Optional<Long> getNextTriggerTime();

    long getStartTime();

    Optional<Long> getEndTime();

    Optional<Long> getPreviousTriggerTime();

    void trigger();

    void trigger(long executeTime);

}
